import requests,unittest
from one.Day4.Tools import Tools
from ddt import ddt,data, unpack

path = r"C:\Users\HP\Desktop\small_address.xlsx"
sheetname = 'Sheet1'
dy = Tools(path, sheetname)
print(dy.getdata())

@ddt
class weidu(unittest.TestCase):
    token = None
    userId=None
    sessionId=None
    #login 登录
    # 登录 login
    host='http://10.59.9.18'
    def test_01_login(self):
        url = weidu.host + '/small/user/v1/login'
        json = {'phone': '17733058407', 'pwd': 'li10140910'}
        login = requests.post(url=url, json=json)
        print(login.json())
        weidu.sessionId = login.json()['result']['sessionId']
        print(weidu.sessionId)
        weidu.userId = str(login.json()['result']['userId'])
        print(weidu.userId)

    #新增收货地址 address
    @unpack
    @data(*dy.getdata())
    def test_02_address(self,realName,phone,address,zipCode,case):
        print('***' + case + '***')
        url=weidu.host+'/small/user/verify/v1/addReceiveAddress'
        headers={'userId':weidu.userId,'sessionId':weidu.sessionId}
        json={'realName':realName,'phone':phone,'address':address,'zipCode':zipCode}
        address=requests.post(url=url,headers=headers,data=json)
        print(address.json())



#执行
if __name__ == '__main__':
    unittest.main()